package com.polaris.live.adapter.level

import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterMeCharmBinding
import com.polaris.live.resp.back_resp.CharmItemVo

/**
 * 魅力等级规则
 *
 * @author Created by 长空 on 2023/10/21/004 19:36
 */
class MeCharmAdapter : BaseBindingAdapter<AdapterMeCharmBinding, CharmItemVo>() {

    override fun convert(holder: VBViewHolder<AdapterMeCharmBinding>, item: CharmItemVo) {
        holder.vb.apply {
            levelView.setNormalCharmLevel(item.level)
            tvDiamond.text = item.value.toString()
            item.privilege?.let {
                val msg = if (it.size == 1) {
                    it[0]
                } else {
                    it.mapIndexed { index, s ->
                        "${index + 1}.$s"
                    }.joinToString(separator = "\n")
                }
                tvPrivilege.text = msg
            }
        }
    }

}